<?php
$str = '';
$mcontent = '';

$template->set_filenames(array(
'view_article'=>'view_article.tpl'
));
if ( empty($paramsArr['aid']) )
	$str .= 'Đang cập nhật !';
else
{
	$sql = "SELECT article.*,topic.tname_vn,topic.tname_en FROM article,topic WHERE topic.tid=article.tid AND autoid=". $paramsArr['aid'] . " order by datepost desc,autoid desc";

	$rs_notice = $link->execute($sql);

	if ( !$rs_notice->EOF )
	{	
		if ( $rs_notice->fields('picture') == 0 )
			$str .= $rs_notice->fields('full_content_' . $_SESSION['cur_lang']);
		else
		{
			$str .= '<img src="images.php?imgid=' . $rs_notice->fields('picture') . '" border="0" align="top" style="float:left">';
			$str .= $rs_notice->fields('full_content_' . $_SESSION['cur_lang']);
		}
		$tid = $rs_notice->fields('tid');
		
		$template->assign_vars(array(
			'T_NEWS_TOPIC_NAME'=>$rs_notice->fields('tname'),
			'T_NEWS_TITLE'=>$rs_notice->fields('title_' . $_SESSION['cur_lang']),
			'T_NEWS_DATE'=>ToVNDate($rs_notice->fields('datepost')),
			'T_NEWS_CONTENT'=>$str,
			'T_NEWS_ACTIONFILTER'=>setURLParams('act=dyn&mod=News&f=filterarticle&tid='.$rs_notice->fields('tid')),
			'T_NEWS_VIEWBYDATE'=>$lang['l_news_viewbydate'],
			'T_NEWS_PRINTPREVIEW_LINK'=>setURLParams('act=dyn&mod=News&f=printpreview&print=yes&aid='.$paramsArr['aid']),
			'T_NEWS_PRINTPREVIEW_TEXT'=>$lang['l_news_print'],
			'T_NEWS_TOPPAGE'=>$lang['l_news_toppage'],
		));

		$rs_notice->close();				
		//lay 5 tin moi nhat 
		$sql = "SELECT * FROM article WHERE tid=$tid AND autoid NOT IN (" . $paramsArr['aid'] . ") ORDER BY datepost DESC";

		$rs_notice = $link->execute($sql);
		
		$auto = 0;
		if ( $rs_notice->recordcount() > 0 )
		{
			$template->assign_block_vars('if_more_news',array(
				'T_NEWS_OTHERNEWS'=>$lang['l_news_othernews']			
			));
			while ( !$rs_notice->EOF )
			{
				if ( $auto++ % 2 == 0 ) $clr = '#FFFFFF';
				else
					$clr = '#FAFAFA';
				$template->assign_block_vars('other_news',array(
					'T_NEWS_OTHERLINK'=>setURLParams('act=dyn&mod=News&f=viewarticle&aid=' . $rs_notice->fields('autoid')),
					'T_NEWS_OTHERTITLE'=>$rs_notice->fields('title_' . $_SESSION['cur_lang']),
					'T_NEWS_OTHERDATE'=>ToVNDate($rs_notice->fields('datepost')),
					'T_NEWS_OTHERROWCOLOR'=>$clr
				));			
				$rs_notice->movenext();
			}
		}
	}
	$rs_notice->close();
}

$template->pparse('view_article');

?>